<?php
  
  
  require "../../../system/framework.php";    
  
  
  $document = "Brief_VV.docx";
  //$document = "telephone-bill-template.doc";
  
  
  
  global $rootDir;
  global $dataDir;
  
  $document = "$rootDir$dataDir/rtf/$document";
  
  
  
  
  $path='I:/Daten/snapol/htdocs/com/zendFramework/api';
  set_include_path(get_include_path() . PATH_SEPARATOR . $path);
  
  include_once "I:/Daten/snapol/htdocs/com/zendFramework/api/Zend/Service/LiveDocx/MailMerge.php";  
  
  
  
  $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge(
    array (
        'username' => 'urslang',
        'password' => '12345678'
    )
);

//$phpLiveDocx->setLocalTemplate('template.docx');
$phpLiveDocx->setLocalTemplate($document);



//$phpLiveDocx->setLocalTemplate('template2.doc');

$phpLiveDocx->assign('name', 'Lang');
$phpLiveDocx->assign('vorname', 'Urs');
$phpLiveDocx->assign('strasse', 'Bannstrasse 4');   
//$phpLiveDocx->assign('company',  'Megasoft Co-operation');


$billConnections = array (
    array ('titel' => '+49 421 335 912', '_url' => '00:00:07'),
    array ('titel' => '+49 42sdfasdf1 335 912', '_url' => '00:00:07'),
    array ('titel' => '+49 421asdfasd 335 912', '_url' => '00:00:07'),
    array ('titel' => '+49 421 335 912', '_url' => '00:00:07'),
    array ('titel' => '+49ddd 421 335 912', '_url' => '00:00:07'),
    array ('titel' => '8888888', '_ur' => '00:00:07'),
    
);
 
$phpLiveDocx->assign('page', $billConnections);




/*
$billConnections = array (
    array ('name' => 'Lang', 'vorname' => 'Urs'),
    array ('name' => 'Klang', 'vorname' => 'Kurs')
    
);
 
$phpLiveDocx->assign('block1', $billConnections);  */





$phpLiveDocx->createDocument();

$document = $phpLiveDocx->retrieveDocument('pdf');

file_put_contents('document.pdf', $document);
//stream_context_create($document);

    header("Content-type: application/pdf");
  
  header("Content-Disposition: attachment; filename=document.pdf");
  header("Pragma: no-cache");
  header("Expires: 0");
  readfile("document.pdf");

  unset($phpLiveDocx);
  
?>
